import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'
Vue.use(Vuex)

// 应用初始状态
const state = {
  adminer: null,
  // 个人权限列表
  selfPurviewList: [],
  purviewList: [],
  purviewName: [],
  globalPurview: [],
  // 编辑器
  editerHtml: ''
}

// 定义所需的 mutations
const mutations = {
  changeSelfPurviewList(state, payload) {
    state.selfPurviewList = payload
  },
  changePurviewList(state, payload) {
    state.purviewList = payload
  },
  changePurviewName(state, payload) {
    state.purviewName = payload
  },
  changeGlobalPurviewName(state, payload) {
    state.globalPurview = payload
  },
  setAdminer(state, adminData) {
      state.adminer = adminData
  },
  setEditerHtml(state, html) {
    state.editerHtml = html
  }
}

// 创建 store 实例
export default new Vuex.Store({
  actions,
  getters,
  state,
  mutations
})
